package com.supermap.originTest2;


import com.supermap.data.*;
import com.supermap.realspace.spatialanalyst.BufferAnalyst3DParameter;
import com.supermap.realspace.spatialanalyst.BufferEndType;
import com.supermap.realspace.spatialanalyst.Geometrist3D;

import java.util.Arrays;


public class Test3DModelFile {

    /**
     * 程序入口点
     * The entrance of the programme.
     */
    public static void main(String[] args) {


//		License license = new License();
//		license.open(65400);
//		System.out.println(license.getFeatureInfo().getExpiredTime());



		Workspace workspace = new Workspace();
		WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(
				"E:\\MapData\\202407\\chongqing\\0723\\0723\\test0723.smwu");
		conInfo.setType(WorkspaceType.SMWU);
		workspace.open(conInfo);
		Datasource d = workspace.getDatasources().get(0);
		DatasetVector datasetVector = (DatasetVector) d.getDatasets().get("result_line2DTo3D");

		Recordset recordset = datasetVector.getRecordset(false, CursorType.STATIC);
		Geometry3D geometry3D = (Geometry3D) recordset.getGeometry();

		BufferAnalyst3DParameter bufferAnalyst3DParameter = new BufferAnalyst3DParameter();
		bufferAnalyst3DParameter.setBufferDistance(1);
		bufferAnalyst3DParameter.setEndType(BufferEndType.ROUND);



		GeoModel3D geoModel3D = (GeoModel3D) Geometrist3D.createBuffer(geometry3D, bufferAnalyst3DParameter, PrjCoordSys.fromEPSG(3857));


		Model model = geoModel3D.getModel();
		System.out.println(model.toStreamFile().length);
		System.out.println(Arrays.toString(model.toStreamFile()));
		byte[] byteArray = model.toStreamFile();




		int splitSize = 4;
		int length = byteArray.length;
		int newSize = ( length / splitSize);


		int[] intArray = new int[newSize];

		for(int i=0;i< newSize;i++) {
			byte[] newByteArray = new byte[newSize];
            System.arraycopy(byteArray, i * splitSize + 0, newByteArray, 0, splitSize);
			intArray[i] = Model.byte4ToInt(newByteArray);
		}
		System.out.println(Arrays.toString(intArray));


//		ModelFileSetting modelFileSetting = new ModelFileSetting();
////		modelFileSetting.setFileFormat(FileFormat.IFC2X3);
//		modelFileSetting.setFileFormat(FileFormat.IFC4);
//
////		modelFileSetting.setFileFormat(FileFormat.FBX);
//		System.out.println(modelFileSetting.getFileFormat());
//
//		modelFileSetting.setFilePath("E:\\MapData\\202405\\三维测试\\导出\\test.ifc");
//		System.out.println(ModelConvertor.toFile(model, modelFileSetting));



	}


}  

